#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <QMessageBox>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <QSocketNotifier>
#include <QTimer>
#include <errno.h>
#include "serialData.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void setSerialData(SerialData data);
    bool openSerial();
    char buf[66];
    char revbuf[66];

private slots:
    void on_closeButton_clicked();
    //void closeSerial();
    void readData();
    void updateData();
    //void clearData();
    //void startAutoSend();

    void on_sendButon_clicked();

    void on_clearButton_clicked();

    void on_autoSend_clicked();

    bool on_openButton_clicked();

    void monitorSetEndable();

signals:
    void serialClosed();
    void finished();

private:
    Ui::MainWindow *ui;

    int fd;
    SerialData setData;
    QString revData;
    QTimer *autoTimer;
    QTimer *timer1;
    QSocketNotifier *monitor;
};

#endif // MAINWINDOW_H
